package com.bdqn.t382.lx;

import java.lang.reflect.Field;

public class Lx02 {
    public static void main(String[] args) {
        try {
            Class<?> aClass = Class.forName("com.bdqn.t382.pojo.Person");
            Object object = aClass.newInstance();
            Field name = aClass.getDeclaredField("name");
            name.setAccessible(true);
            System.out.println("赋值前:"+name.get(object));
            name.set(object, "小明");
            System.out.println("赋值后:"+name.get(object));
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
